package com.googlecode.animeclassifier.attribute;

import java.util.regex.Pattern;

public class Rule {
	String regex;
	Attributes type;
	String value;
	Pattern pattern;
	
	private Rule(String regex, String value) {
		super();
		this.regex = regex;
		pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
		this.value = value;
	}
	
	/**
	 * @param regex
	 * @param type
	 * @param value
	 */
	public Rule(String regex, Attributes type, String value) {
		this(regex, value);
		this.type = type;
	}
	
	/**
	 * @param regex
	 * @param type
	 * @param value
	 */
	public Rule(String regex, int type, String value) {
		this(regex, value);
		this.type = Attributes.getAttributesByIdx(type);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Rule: {regex: " + regex + ", type: " + type + ", value: " + value + ", pattern: " + pattern + "} ";
	}
}
